<div class="modal-body pageContent">
	<div class="row">
        <div class="col-lg-12 col-lg-offset-2">
                <!-- <form action="/order/addOrder" enctype="multipart/form-data" method='post' id="orderForm"> -->
            <form action="/order/updateInfo" id="orderFormEditInfo" method="post" class="form-horizontal" enctype="multipart/form-data">
                 <div class="form-group"style='height: 40px;'>
                   <div class="col-lg-12">
                         <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;"><span class="indicator">*</span>订单号</label><span style="font-weight: 500;">：</span>
                        <input type="text"  readonly class="form-control" name="orderId" style=" width: 230px;display: inline-block;" value="{{orderId}}"/>
                         <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;"><span class="indicator">*</span>设备数目</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="deviceNum" style=" width: 230px;display: inline-block;" value="{{deviceNum}}" />
                    </div>
                 </div>
                 <div class="form-group">
                    <div class="col-lg-12">
                        <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;">水司号</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="beginWaterDivision" style=" width: 230px;display: inline-block;"  id="beginWaterDivision" value="{{beginWaterDivision}}"   placeholder="开始水司号"/>
                        <input type="text" class="form-control" name="endWaterDivision" style="margin-left:118px; width: 230px;display: inline-block;"  id='endWaterDivision' value="{{endWaterDivision}}"  placeholder="结束水司号"/>
                        <div class="row alarm" style='color:#a94442;'>
                            <div class="col-sm-12" style=" padding-left: 43px;">
                              <span >开始水司号和结束水司号必须同时填写或者不填写</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                     <div class="col-lg-12">
                         <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;">客户</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="customer" style=" width: 230px;display: inline-block;" value="{{customer}}"/>
                         <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;">固件版本</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="firmwareVersion" style=" width: 230px;display: inline-block;" value="{{firmwareVersion}}"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-12">
                        <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;"><span class="indicator">*</span>软件版本</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="softwareVersion" style=" width: 230px;display: inline-block;" value="{{softVersion}}"/>
                        <label class="col-lg-12 control-label" style=" width: 100px;text-align: center;"><span class="indicator">*</span>硬件版本</label><span style="font-weight: 500;">：</span>
                        <input type="text" class="form-control" name="hardwareVersion" style=" width: 230px;display: inline-block;" value="{{hardwareVersion}}" />
                    </div>
                </div> 
                 <div class="form-group" style=" margin-left: 10px;">
                        <!-- <div class="form-group col-md-6 prl15" >
                                <label class="col-lg-12 control-label" style="padding-left: 0px !important;">母线</label>
                                <div class="col-lg-12" style="padding-left: 0px !important;">
                                    <input type="file" name="busFile" />
                                </div>
                        </div> -->
                    <label class="col-lg-12 control-label" style="width: 103px;float: left;text-align: center;">母线</label><span style="float: left; font-weight: 500;">：</span>
                    <div class="bfb91">
                         <input type="file" name="busFile"  style=" width: 230px;display: inline-block;"/>
                    </div>
                    <label class="col-lg-12 control-label" style="width: 103px;float: left;text-align: center;"><span class="indicator">*</span>工序集</label><span style="float: left; font-weight: 500;">：</span>
                    <div class="bfb91">
                          <select id="processCollectionId" class="selectpicker show-tick form-control" name="processSchemeId">
                             <option value="{{processSchemeId}}"  selected  style="display:none">请选择工序集</option>
                          </select>
                    </div>
               </div>
               <div class="form-group" style=" margin-top: 75px; margin-left: 10px;">
                     <label class="col-lg-12 control-label" style="width: 103px;float: left;text-align: center;"><span class="indicator">*</span>产品配置</label><span style="float: left; font-weight: 500;">：</span>
                    <div class="bfb91">
                          <select id="productConfigCollectionId" class="selectpicker show-tick form-control" name="configId">
                             <option value="{{configId}}"  selected  style="display:none">请选择产品配置</option>
                          </select>
                    </div>
                    <label class="col-lg-12 control-label" style="width: 103px;float: left;text-align: center;"><span class="indicator">*</span>产品类型</label><span style="float: left; font-weight: 500;">：</span>
                    <div class="bfb91">
                          <select id="productTypeCollectionId" class="selectpicker show-tick form-control" name="productType">
                            <option value="{{productType}}"  selected  style="display:none">请选择产品类型</option>
                          </select>
                    </div>
               </div>
               <div class="form-group">
                    <div class="col-lg-12" style=" top: 20px;left: 20px;">
                            <button type="button" class="btn" onclick="checkFile()" style="background-color: #4cb6cb;">查看母线文件</button>
                     </div>
               </div>

                <input type="hidden" class="form-control" name="id" value="{{id}}" />
                <textarea  id= "busFile" style="display: none" >{{busFile}}</textarea>
            </form>
        </div>
    </div>
</div>
<div class="modal-footer pageFooter">
   <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    <button  class="btn btn-primary"  type="submit" id="displayBtn">保存</button>
   
</div>
<script>
    $(function(){
        $('#orderFormEditInfo')
        .bootstrapValidator({
            message: '此值无效',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                orderId: {
                    validators: {
                        notEmpty: {
                            message: '请填写订单号'
                        },
                        regexp:{
                            regexp: /^[a-zA-Z0-9_]{0,15}$/,
                            message:"订单号只能由字母数字下划线组成，长度不得超过15个字符"
                        }
                    }
                },
                deviceNum: {
                    validators: {
                        notEmpty: {
                            message: '请填写设备数目'
                        },
                    }
                },
                beginWaterDivision: {
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9]{0,12}$/,
                            message: 'SN只能由字母、数字组成,长度不得超过12个字符'
                        }
                    }
                },
                endWaterDivision: {
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9]{0,12}$/,
                            message: 'SN只能由字母、数字组成,长度不得超过12个字符'
                        }
                    }
                },
                softwareVersion: {
                    validators: {
                        notEmpty: {
                            message: '请填写软件版本'
                        },
                    }
                },
                hardwareVersion: {
                    validators: {
                        notEmpty: {
                            message: '请填写硬件版本'
                        },
                    }
                },
                processSchemeId:{
                    validators: {
                        notEmpty: {
                            message: '请选择工序集'
                        },
                    }
                },
                 configId:{
                    validators: {
                        notEmpty: {
                            message: '请选择产品配置'
                        },
                    }
                },
                productType:{
                    validators: {
                        notEmpty: {
                            message: '请选择产品类型'
                        },
                    }
                },

            }
        })
        .on('success.form.bv', function(e) {
            e.preventDefault();
            var $form = $(e.target);
            var bv = $form.data('bootstrapValidator');
            var begin =   $('.beginWaterDivision').val();
            var end =   $('.endWaterDivision').val();
            if (begin==""&&end!=""||begin!=""&&end=="") {
                if($('.alarm')!=undefined){
                    $('.alarm').empty();
                }
             $('.alarm').html("两个输入框必须同时为空或者不为空!").css('margin-left',"10px");
             return false;
            }
            var formData = new FormData($("#orderFormEditInfo")[0]); //换成上面这种表单数据绿色提交，file格式识别不到 
            $.ajax({  
                  url: '/order/updateInfo' ,  
                  type: 'POST',  
                  data: formData,  
                  async: false,  
                  cache: false,  
                  contentType: false,  
                  processData: false,  
                  success: function (result) { 
                    //   debugger
                    if(result.length===9371){   
                                location.href="/severError";
                        }else{  
                            var successStr = JSON.parse(result);
                            if(successStr.statusCode=="200"){
                                $('#orderUpdateInfo').modal('hide');
                                toastr.success(successStr.message+'!');
                                $("#ArbetTable").bootstrapTable('refresh');
                            }else{                
                                // $('#orderUpdateInfo').modal('hide');
                                toastr.warning(successStr.message+'!'); 
                                // $("#ArbetTable").bootstrapTable('refresh');
                            }
                        }
                  },  
                  error: function (result) {      
                    if(result.status===503||result.status===500){ 
                        $('#orderUpdateInfo').modal('hide');
                        toastr.error("服务端数据异常"+'!');
                    }
                  }  
             });
        });
      getprocessCollection();
      getConfigCollection();    
      getConfigTypeCollection(); 
    })
    

    function order_edit_controlConform(num){
        $.ajax({
            url:'/order/operateOrder',
            type:'post',
            data:{'orderId':'{{orderId}}','operate':num },
            dataType:'json',
            success:function(json){
                if(json.statusCode == '200'){
                    toastr.success(json.message);
                }else{            //300情况下
                    toastr.error(json.message);
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
                toastr.error(textStatus+'!');
            }
        })
    }

    function  checkFile(){
        // var busFileStr= $('#busFile').val().replace(/\r\n/g, 'br').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
        // console.log($('#busFile').val());
        var busFileStr= $('#busFile').val()
        // .replace(/br/g, '\r\n').replace(/\s/g, ' ')
        Ewin.dialog({
        id:'orderCheckFile',
        url:'/order/checkFile',
        title:'母线文件内容',
        data:{busFile:busFileStr},
        width:600,
        height:600
        })
    } 
    
    function getConfigCollection(){
        $.ajax({
            url:'/order/getConfigList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                     if(item.description!=""){
                          if(item.id=="{{'configEntity[id]'}}"){
                               $('#productConfigCollectionId').append('<option selected value="'+item.id+'">'+item.name+'('+item.description+')'+'</optinon>');
                          }else{
                               $('#productConfigCollectionId').append('<option value="'+item.id+'">'+item.name+'('+item.description+')'+'</optinon>');
                          }
                     }else{
                           if(item.id=="{{'configEntity[id]'}}"){
                               $('#productConfigCollectionId').append('<option selected value="'+item.id+'">'+item.name+'</optinon>');
                          }else{
                               $('#productConfigCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                          }
                     }
            })
            $('#productConfigCollectionId').selectpicker('render');
            $('#productConfigCollectionId').selectpicker('refresh');
            }
          })
    }

    function getConfigTypeCollection(){
        $.ajax({
            url:'/order/getTypeList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                            if(item.operator!=""){
                                if(item.id=="{{'type[id]'}}"){ //运营商一定存在
                                $('#productTypeCollectionId').append('<option selected value="'+item.id+'">'+item.name+'('+item.operator+')'+'</optinon>');
                                }else{
                                $('#productTypeCollectionId').append('<option value="'+item.id+'">'+item.name+'('+item.operator+')'+'</optinon>');
                                }
                              }
              })
              $('#productTypeCollectionId').selectpicker('render');
              $('#productTypeCollectionId').selectpicker('refresh');
            }
          })
    }

    function getprocessCollection(){
          $.ajax({
            url:'/order/processList',
            type:'POST',
            dataType:'json',
            // data:{"schemeId":'{{schemeId}}'},
            success:function(json){
               $.each(json,function(i,item){
                if(item.demo!=""){
                              if(item.name=="{{'processSchemeEntity[name]'}}"){ //工序集采用的是复制的数据，存在id不一致的情况
                                    // $('#processCollectionId').text(item.name+'('+item.demo+')');
                                  $('#processCollectionId').append('<option selected value="'+item.id+'">'+item.name+'('+item.demo+')'+'</optinon>');    
                              }else{
                                  $('#processCollectionId').append('<option  value="'+item.id+'">'+item.name+'('+item.demo+')'+'</optinon>');    
                                  }
                }else{
                              if(item.name=="{{'processSchemeEntity[name]'}}"){
                                 // $('#processCollectionId').text(item.name);
                              $('#processCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                               }else{//填充值
                              $('#processCollectionId').append('<option value="'+item.id+'">'+item.name+'</optinon>');
                             } 
                }
            })
            $('#processCollectionId').selectpicker('render');
            $('#processCollectionId').selectpicker('refresh');
            }
          })
     }
 
</script>